// pages/leader/stories/stories.js
var api = require('../../config/api.js');
var util = require('../../utils/util.js');
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    bookList: [],
    imgUrl:api.RootUrl,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    that.getBookList();
  },

  getBookList:function(){
    let that = this
    util.request(api.BooksList, { keyword:'平凡的世界',categoryId:8}).then(function(res){
      if(res.errno==0){
        that.setData({
          bookList: res.data.bookList,
        });
      }
    });  
  },

  startRead:function(e){
    let that = this;
    let book = e.currentTarget.dataset.book;
    wx.navigateTo({
      url: '/pages/readBook/detail/detail?bookId=' + 1 + '&bookName=' + book.name + '&bookAuthor=' + book.author,
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})